<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>
<%@ taglib uri="http://eureka.yigolden.net/stringutils/sutaglib/1.0" prefix="su"%>
<!DOCTYPE html>
<html>
  <head>
    <meta charset="utf-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0, user-scalable=no">
    <!-- 上述3个meta标签*必须*放在最前面，任何其他内容都*必须*跟随其后！ -->

    <title>完善个人信息</title>

    <!-- Bootstrap core CSS -->
    <link href="<%=request.getContextPath() %>/static/css/bootstrap.min.css" rel="stylesheet">

    <!-- Custom styles for this template -->
    <link href="<%=request.getContextPath() %>/static/css/signin.css" rel="stylesheet">

    <!-- HTML5 shim and Respond.js for IE8 support of HTML5 elements and media queries -->
    <!--[if lt IE 9]>
      <script src="<%=request.getContextPath() %>/static/js/html5shiv.min.js"></script>
      <script src="<%=request.getContextPath() %>/static/js/respond.min.js"></script>
    <![endif]-->
    
    <script type="text/javascript">
    
	function submitForm(){
		

		var realName = document.getElementById("realName");
		
		var gender=document.getElementById("gender");
		var birthday = document.getElementById("birthday");
		var nation=document.getElementById("nation");
		var belief=document.getElementById("belief");
		var phoneNumber = document.getElementById("phoneNumber");
		var qq = document.getElementById("qq");
		var email = document.getElementById("email");
		var address = document.getElementById("address");
		var university = document.getElementById("university");
		var major = document.getElementById("major");
		var domitory=document.getElementById("domitory");
		
		if(realName.value==""){
			alert("真实姓名不能为空！");
			realName.focus();
			return false;
		}
		
		if(gender.value==""){
			alert("性别不能为空！");
			gender.focus();
			return false;
		}
	
		if(birthday.value==""){
			alert("生日不能为空！");
			birthday.focus();
			return false;
		}
		if(nation.value==0){
			alert("请选择民族！");
			nation.focus();
			return false;
		}
		if(belief.value==0){
			alert("请选择政治面貌！");
			belief.focus();
			return false;
		}
		
		if(phoneNumber.value==""){
			alert("手机号码不能为空！");
			phoneNumber.focus();
			return false;
		}
		
		if(!(/^1[0-9][0-9]\d{4,8}$/.test(phoneNumber.value))){
			alert("请输入完整的11位手机号！");
			phoneNumber.focus();
			return false;
		}
		if(qq.value==""){
			alert("QQ不能为空！");
			qq.focus();
			return false;
		}
		if(email.value==""){
			alert("Email不能为空！");
			email.focus();
			return false;
		}
		
		if(address.value==""){
			alert("地址不能为空！");
			address.focus();
			return false;
		}

		if(university.value==0){
			alert("就读院校不能为空！");
			university.focus();
			return false;
		}
		if(major.value==""){
			alert("所学专业不能为空！");
			major.focus();
			return false;
		}
		if(domitory.value==""){
			alert("寝室号不能为空！");
			domitory.focus();
			return false;
		}

		return true;
	}

    </script>
    
    
  </head>

  <body>

  <div class="container">
	<h1 style="font-family:华文行楷;" >好室友<small>网</small> </h1>
    <div class="row">
		<div class="col-sm-3">
		</div>
		<div class="col-sm-6">
		<form class="form-horizontal" method="post" onsubmit="return submitForm();">
        <input type="hidden" name="action" value="detailinfo" />    
             
        <div class="form-group">
    		<label for="inputPassword3" class="col-sm-4 control-label">真实姓名：</label>
    		<div class="col-sm-8">
      			<input type="text" class="form-control" id="realName" name="realName" placeholder="真实姓名……">
    		</div>
  		</div>  
  
  		<div class="form-group">
    		<label for="inputPassword3" class="col-sm-4 control-label">性别：</label>
    		<div class="col-sm-8">
    			<input type="text" class="form-control" id="gender" name="gender" placeholder="性别……">
    		
    		</div>
  		</div>  
  		
  		<div class="form-group">
    		<label for="inputPassword3" class="col-sm-4 control-label">生日：</label>
    		<div class="col-sm-8">
      			<input type="date" class="form-control" id="birthday" name="birthday" placeholder="生日（格式如：2008-09-01）……">
    		</div>
  		</div>  
  		
  		
  		<div class="form-group">
    		<label for="inputPassword3" class="col-sm-4 control-label">民族：</label>
    		<div class="col-sm-8 dorpdown">
    		<c:if test="${nations ne null }">
  			<select class="form-control" id="nation" name="nation">
  				<option value="0">请选择民族</option>
  				<c:forEach var="item" items="${nations }">
  					<option value="${item.name }">${item.name}</option>
  				</c:forEach>
  			</select>
  			</c:if>
  			<c:if test="${nations eq null }">
  			<select class="form-control" id="nation" name="nation">
  				<option value="0">民族加载失败</option>
  			</select>
  			</c:if>
  			</div>
  		</div> 
  		
  		<div class="form-group">
    		<label for="inputPassword3" class="col-sm-4 control-label">政治面貌：</label>
    		<div class="col-sm-8 dropdown">
    		<select class="form-control" id="belief" name="belief">
  				<option value="0">选择政治面貌</option>
  				<option value="1">中共党员</option>
  				<option value="2">中共预备党员</option>
  				<option value="3">共青团员</option>
  				<option value="4">民革党员</option>
  				<option value="5">民盟盟员</option>
  				<option value="6">民建会员</option>
  				<option value="7">民进会员</option>
  				<option value="8">农工党党员</option>
  				<option value="9">致公党党员</option>
  				<option value="10">九三学社社员</option>
  				<option value="11">台盟盟员</option>
  				<option value="12">无党派民主人士</option>
  				<option value="13">普通公民</option>
			</select>
			</div>
  		</div> 
  		
  		<div class="form-group">
    		<label for="inputPassword3" class="col-sm-4 control-label">电话：</label>
    		<div class="col-sm-8">
      			<input type="text" class="form-control" id="phoneNumber" name="phoneNumber" placeholder="电话……">
    		</div>
  		</div>
  
  		<div class="form-group">
    		<label for="inputPassword3" class="col-sm-4 control-label">QQ：</label>
    		<div class="col-sm-8">
      			<input type="text" class="form-control" id="qq" name="qq" placeholder="QQ……">
    		</div>
  		</div>
  		
  		<div class="form-group">
    		<label for="inputPassword3" class="col-sm-4 control-label">Email：</label>
    		<div class="col-sm-8">
      			<input type="text" class="form-control" id="email" name="email" placeholder="Email……">
    		</div>
  		</div>
  		
  		<div class="form-group">
    		<label for="inputPassword3" class="col-sm-4 control-label">家庭地址：</label>
    		<div class="col-sm-8">
     			 <input type="text" class="form-control" id="address" name="address" placeholder="地址……">
    		</div>
  		</div>
  		
  		
  		
  		<div class="form-group">
    		<label for="inputPassword3" class="col-sm-4 control-label">就读院校：</label>
    		<div class="col-sm-8 dorpdown">
    		<c:if test="${universities ne null }">
  			<select  disabled class="form-control" id="university" name="university">
  				<option value="0">请选择院校</option>
  				<c:forEach var="item" items="${universities }">
  					<c:if test="${item.id eq allocation.universityid }">
  						<option value="${item.name }" selected="selected">${item.name}</option>			
  					</c:if>
  					<c:if test="${item.id ne allocation.universityid }">
  					<option value="${item.name }">${item.name}</option>
  					</c:if>
  				</c:forEach>
  			</select>
  			</c:if>
  			<c:if test="${universities eq null }">
  			<select class="form-control" id="university" name="university">
  				<option value="0">院校加载失败</option>
  			</select>
  			</c:if>
  			<a href="<%=request.getContextPath()%>/Domitory/UpdateDomitory">我要更改</a>
  			</div>
  		</div> 
  		
  		<div class="form-group">
    		<label for="inputPassword3" class="col-sm-4 control-label">所学专业：</label>
    		<div class="col-sm-8">
     			 <input type="text" class="form-control" id="major" name="major" placeholder="所学专业……">
    		</div>
  		</div>
  		
  		
  		<div class="form-group">
    		<label for="inputPassword3" class="col-sm-4 control-label">寝室号：</label>
    		<div class="col-sm-8">
    			 <c:if test="${allocation ne null }">
     			 <input disabled  type="text" class="form-control" id="domitory" value="${allocation.domitoryid}" name="domitory" placeholder="寝室号……">
     			 </c:if>
     			 <c:if test="${allocation eq null }">
     			 <input type="text" class="form-control" id="domitory" name="domitory" placeholder="寝室号……">
    			 </c:if>
    			 <a href="<%=request.getContextPath()%>/Domitory/UpdateDomitory">我要更改</a>
    		</div> 		
  		</div>
  		

  		
  		<div class="form-group">
    		<div class="col-sm-offset-4 col-sm-8">
      			<div class="col-sm-6">
     				 <button type="submit" class="btn btn-success">完善信息</button>
     		    </div>
      			<div class="col-sm-6">
      				<button type="reset" class="btn btn-warning">重新填写</button>
      			</div>	
    		</div>
    		
    		<div class="col-sm-offset-4 col-sm-8">
    		<c:if test="${errorCode eq 0 }">
          		<div class="alert alert-warning" role="alert" id="alert-warning">验证失败！</div>
        	</c:if>
			<c:if test="${errorCode eq 1 }">
          		<div class="alert alert-warning" role="alert" id="alert-warning">添加成功</div>
        	</c:if> 
        	<c:if test="${errorCode eq 2 }">
          		<div class="alert alert-warning" role="alert" id="alert-warning">您已经添加过详细信息！不能重复添加！</div>
        	</c:if>  
        	</div>
  		</div>
        
        
        <input type="hidden" name="referrer" value="${fn:escapeXml(referer) }" />
        
      </form>
      </div>
      <div class="col-sm-3"></div>
     </div>

    </div> <!-- /container -->

	<script src="<%=request.getContextPath() %>/static/js/jquery.min.js" ></script>
	<script src="<%=request.getContextPath() %>/static/js/bootstrap.min.js"></script>
    <!-- IE10 viewport hack for Surface/desktop Windows 8 bug -->
    <script src="<%=request.getContextPath() %>/static/js/ie10-viewport-bug-workaround.js"></script>
  </body>
</html>